package com.kun.video.ui.pane;

import cn.hutool.core.util.ArrayUtil;
import com.kun.video.ui.KunComponent;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * TODO
 *
 * @author gzc
 * @since 2025/3/20
 **/
public class TitleVerBox extends VBox implements KunComponent {
    private static final Logger log = LoggerFactory.getLogger(TitleVerBox.class);
    private static final String CSS_CLASS = "title-ver-box";

    private final Label titleLabel = new Label();
    private final KunHorBox kunHorBox = new KunHorBox();

    public TitleVerBox(String title, Node... nodes) {
        titleLabel.setText(title);
        if (ArrayUtil.isNotEmpty(nodes)) {
            addItems(nodes);
        }
        initialize();
    }

    @Override
    public Parent getNode() {
        return this;
    }

    @Override
    public String getStyleName() {
        return CSS_CLASS;
    }

    @Override
    public void initStyleClass() {
        KunComponent.super.initStyleClass();
        titleLabel.getStyleClass().setAll("title");
    }

    @Override
    public void initLayout() {
        getChildren().addAll(titleLabel, kunHorBox);
    }

    @Override
    public void initStyle() {
        kunHorBox.setAlignment(Pos.CENTER);
    }

    @Override
    public void initDimensions() {
    }

    @Override
    public void reactiveDimensions(double width, double height) {
    }

    @Override
    public void initListeners() {
    }

    @Override
    public void dispose() {
    }

    @Override
    public void initData() {
    }

    public ObservableList<Node> getItems() {
        return kunHorBox.getChildren();
    }

    public void addItems(Node... nodes) {
        kunHorBox.getChildren().addAll(nodes);
    }

}
